<template>
<section>
  <div class="school-name">{{schoolName}}</div>
  <div class="school-description"  style="width:50%;">
    <span style="font-weight:bold">地址：</span>
    {{provinceName}}{{cityName == '市辖区'?'':cityName}}{{districtName== '市辖区'?'':districtName}}{{address== null?'':address}} 
  </div>
  <div class="school-description" style="width:45%;"><span style="font-weight:bold">学段：</span> {{phases}}</div>
  
  <el-row :gutter="40" class="panel-group">

    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="checkMenu('/classes')>=0?$router.push('/classes'):''">
        <div class="card-panel-icon-wrapper icon-classes">
          <svg-icon icon-class="education" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            班级数
          </div>
          <div class="card-panel-num">
			    {{classesNum}}
          </div>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="checkMenu('/schoolteacher')>=0?$router.push('/schoolteacher'):''">
        <div class="card-panel-icon-wrapper icon-peoples">
          <svg-icon icon-class="peoples" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            教师人数
          </div>
          <div class="card-panel-num">
			    {{teacherNum}}
          </div>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="checkMenu('/schoolstudent')>=0?$router.push('/schoolstudent'):''">
        <div class="card-panel-icon-wrapper icon-people">
          <svg-icon icon-class="people" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            学生人数
          </div>
          <div class="card-panel-num">
			    {{studentNum}}
          </div>
        </div>
      </div>
    </el-col>
  </el-row>
   <div class="table_content">
        <header>
            <div class="title">
                <h3>学校产品</h3>
            </div>
        </header>
        <div class="list_area" v-if="tableData.length > 0">
            <ul>
                <li v-for="(item,index) in tableData" :key="index">
                    <div class="classDetail">
                        <div>{{item.productName}}</div>
                        <div>{{item.useType==1?"购买":(item.useType==0?"已过期":"试用")}}</div>
                        <div>{{item.startDate + "&nbsp;至&nbsp;" + item.endDate}}</div>
                    </div>
                </li>
            </ul>
            <div class="clearfloat"></div>
        </div>
        <div class="noData" v-else>
            <span>暂无可用产品</span>
        </div>
    </div>
  </section>
  
  
</template>

<script>
	import util from '../../common/js/util'
	import { SysApi } from '@/api/index'

	export default {
  data() {
		
			return {
				schoolName: JSON.parse(sessionStorage.getItem("schoolName")),
				schoolId:  JSON.parse(sessionStorage.getItem("schoolId")),
        provinceName: '',
        cityName: '',
        districtName: '',
        address: '',
        classesNum: '',
        teacherNum: '',
        studentNum: '',
        tableData: [],
        phaseList: [],
        phases:'',
        menuList:[],
				listLoading: true,


        }
		},
		created(){
			if(this.$route.params.schoolId != undefined){
				sessionStorage.setItem("schoolId", JSON.stringify(this.$route.params.schoolId));
				this.schoolId = this.$route.params.schoolId;
			}else{
				this.schoolId = JSON.parse(sessionStorage.getItem("schoolId"));
			}  
			// console.log(this.schoolId);
			this.getSchoolInfo();
      this.getSchoolProductList();
      
      //获取菜单列表
	  	this.getMenuList();	

		},
		
  methods: {
      handleSetLineChartData(type) {
        this.$emit('handleSetLineChartData', type)
      },
      //获取学段列表
			getSchoolInfo(){
				let params = {
					schoolId: this.schoolId
				};
				SysApi.getSchoolInfo(params, res => {
					if (res!=null)
					{
            this.schoolName = res.schoolName;
            this.provinceName = res.provinceName;
            this.cityName = res.cityName;
            this.districtName = res.districtName;
            this.address = res.address;
            this.classesNum = res.classesNum;
            this.teacherNum = res.teacherNum;
            this.studentNum = res.studentNum;
            this.phaseList = res.schoolPhaseList;
            if  (this.phaseList!=null && this.phaseList.length>0 )
            {
              for(var i=0; i<this.phaseList.length; i++){
                if (i===0)
                {
                  this.phases = this.phaseList[i].phaseName;
                }
                else{
                  this.phases = this.phases  + "," + this.phaseList[i].phaseName;
                }
              }
            }
					}
				}, (errorType, error) => {
				})
      },
      //获取菜单列表
      getMenuList(){
        
        this.menuList = sessionStorage.getItem('menuList');
      },
      //获取菜单列表
      checkMenu(item){
        var index = this.menuList.indexOf(item);
        return index
      },
      //获取产品列表
			getSchoolProductList(){
				let params = {
					schoolId: this.schoolId
        };
        
				SysApi.getSchoolProductList(params, res => {
					if (res!=null)
					{
            this.tableData = res;
					}
				}, (errorType, error) => {
				})
			},
  }
}
</script>

<style lang="scss" scoped>
.school-name {
    height: 48px;
    cursor: pointer;
    font-size: 24px;
    color: blue;
    position: relative;
    overflow: hidden;
    background: #fff;
    text-align:center;
}
.school-description {
    height: 18px;
    position: relative;
    display: inline-block;
    font-size: 16px;
    color: #666;
    background: #fff;
    text-align:center;
    margin-top: 15px;
}
.panel-group {
  margin-top: 68px;

  .card-panel-col {
    margin-bottom: 32px;
    margin-left: 50px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-classes {
        background: #36a3f7;
      }

      .icon-peoples {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-classes {
      color: #36a3f7;
    }

    .icon-peoples {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 20px;
      margin-right: 30px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 15px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 32px;
      }
    }
  }
}
 .table_content{
        width: 100%;
        height: auto;
        margin-top: 20px;
        header{
            width: 100%;
            height: 51px;
            .title{
                width: 100px;
                height: 23px;
                line-height: 23px;
                border-left: 5px solid blue;
                padding-left: 5px;
                display: inline-block;
                margin-top: 12px;
                h3{
                    margin: 0;
                }
            }
        }
        .list_area{
            ul{
				min-height: 150px;
				padding-top: 1px;
				padding-left: 30px;
				li{
					float: left;
					list-style: none;
					width: 200px;
					height: 150px;
					margin-left: 5%;
					margin-top: 10px;
					margin-right: 5%;
					margin-bottom: 20px;
					border-style: groove;
					border-width: 1px;
					border-color: rgba(150, 170, 255, 0.863);
					-webkit-box-shadow: 4px 6px 9px 2px rgba(199, 199, 199, 0.2);
					-moz-box-shadow: 4px 6px 9px 2px rgba(199, 199, 199, 0.2);
					box-shadow: 4px 6px 9px 2px rgba(199, 199, 199, 0.2);
					color: #000000;
					div.classDetail{
                        text-align: center;

						line-height: 40px;
						div:nth-of-type(1){
							background: #426AFF;
							color: #FFFFFF;
						}
                        div:nth-of-type(2){
							color: rgb(255, 0, 0);
                            line-height: 50px;
						}
                        div:nth-of-type(3){
							color: rgb(255, 0, 0);
						}
					}
				}
			}
			.clearfloat{clear:both;height:0;font-size: 1px;line-height: 0px;} 
        }
        .noData{
            text-align: center;
            color: #909399;
            line-height: 100px;
        }
    }
@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
<style>
.el-table >.el-table__fixed {
    height: 100% !important; 
  }
.el-table >.el-table__fixed-right {
    height: 100% !important; 
  }
.el-table--scrollable-x .el-table__body-wrapper {
    z-index: 1;
  }
</style>
